package com.gin.no_gay_alliance.fragment.notice;

import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;

import com.gin.no_gay_alliance.activity.TopicReadActivity;
import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemNoticeReplyBinding;
import com.gin.no_gay_alliance.utils.ViewUtils;
import com.gin.no_gay_alliance.viewmodel.notice.RecommendNoticeModel;

/**
 * 提醒消息 - 赞踩
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/11 13:44
 **/
public class RecommendNoticeFragment extends BaseNoticeTabFragment<ItemNoticeReplyBinding, RecommendNoticeModel> {
    @Override
    protected ItemNoticeReplyBinding buildBinding(LayoutInflater inflater) {
        return ItemNoticeReplyBinding.inflate(inflater);
    }

    /**
     * 绑定数据
     */
    @Override
    protected void onBindViewHolder(BaseBindingRecyclerViewAdapter.ViewHolder<ItemNoticeReplyBinding> holder, @NonNull ItemNoticeReplyBinding b, int position, RecommendNoticeModel item) {
        b.tvContent.setText(item.description);
        b.tvTimestamp.setText(item.datetime);
        b.tvTopicTitle.setText(item.topicTitle);
        ViewUtils.setGone(item.read, b.tvNoRead);
    }

    /**
     * 点击事件统一处理
     *
     * @param v 被点击的View
     */
    @Override
    public void onClick(View v) {
        super.onClick(v);
        RecommendNoticeModel recommendNotice = (RecommendNoticeModel) v.getTag();
        if (recommendNotice.page != null && recommendNotice.page > 0) {
            TopicReadActivity.startActivity(requireActivity(), null
                    , recommendNotice.topicId
                    , recommendNotice.page
                    , recommendNotice.replyId
                    , recommendNotice.page
            );
        } else {
            TopicReadActivity.startActivity(requireContext(), recommendNotice.replyId);
        }
    }
}
